package com.groupbuying.store.controller.forInternal;

import com.groupbuying.store.connector.SysconfigFeign;
import com.groupbuying.store.utils.JSONUtils;
import com.groupbuying.store.utils.ParamUtils;
import com.groupbuying.store.utils.R;
import com.groupbuying.store.service.ChainStoresApiService;
import com.groupbuying.store.utils.ReturnUtils;
import com.groupbuying.store.utils.apiresult.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @anthor wenguoqiang
 * @date: 2019/01/30 11:53
 * @company 够样
 * @des
 **/

@Api("服务商门店接口")
@RestController
@RequestMapping("/shop")
public class ChainStoreController {
    private static Logger log = LoggerFactory.getLogger(ChainStoreController.class);

    @Autowired
    private ChainStoresApiService chainStoresApiService;
    @Autowired
    private SysconfigFeign sysconfigFeign;


    /**
     * 查询子门店列表
     * @return
     */
    @ApiOperation(value = "查询门店列表", notes = "查询门店列表接口")
    @GetMapping("/getShopList")
    public R getShopList(@RequestParam Map<String, Object> params) {
        return chainStoresApiService.getShopListByProviderId(params);
    }


    /**
     * 查询通过的子门店列表
     * @auth zmlmagic
     * @return
     */
    @ApiOperation(value = "查询通过门店列表", notes = "查询通过门店列表")
    @GetMapping("/getCrossShopList")
    public R getCrossShopList(@RequestParam Map<String, Object> params) {
        return chainStoresApiService.getCrossStoreByProviderId(params);
    }


    /**
     * 查询子门店优惠规则
     *
     * @return
     */
    @ApiOperation(value = "查询子门店优惠规则", notes = "查询子门店优惠规则")
    @GetMapping("/getShopOpexList")
    public R getShopOpexList(@RequestParam Map<String, Object> params) {
        return chainStoresApiService.getStoreByProviderId(params);
    }

    /**
     * 新增子门店
     *
     * @return
     */
    @ApiOperation(value = "新增门店", notes = "新增门店接口")
    @PutMapping("/save")
    public R save(@RequestBody Map<String, Object> params) {
        return chainStoresApiService.addChildStore(params);
    }


    /**
     * 修改门店后再次提交
     * 因相关信息较多不便修改
     * 补丁方案，新建门店并把原门店置删除位
     * @auther zmlmagic
     * */
    @ApiOperation(value = "再次提交门店", notes = "再次提交门店")
    @PutMapping("/saveAgain")
    public R saveAgain(@RequestBody Map<String, Object> params) {
        return chainStoresApiService.addChildStoreAgain(params);
    }

    /**
     * 保存对已经正常填报商户的修改
     * @param params
     * @return
     */
    @ApiOperation(value = "再次提交门店", notes = "再次提交门店")
    @PutMapping("/saveReportedUpdate")
    public R saveReportedUpdate(@RequestBody Map<String, Object> params) {
        return chainStoresApiService.saveReportedUpdate(params);
    }

    /**
     * 获取子门店详情
     */
    @ApiOperation(value = "获取门店详情", notes = "获取门店详情接口")
    @PostMapping("/getStoreView")
    @ResponseBody
    public ApiResult getStoreView(@RequestBody Map<String, Object> params) {
        return chainStoresApiService.getChildStoreView(params);
    }

    /**
     * 银盛-获取企业类型
     *
     * @return
     */
    @ApiOperation(value = "获取企业类型", notes = "获取企业类型")
    @GetMapping("/getCompanyType")
    public R getCompanyType(@RequestParam Map<String, Object> params) {
        return sysconfigFeign.getKeyCompanyType(params);
    }

    /**
     * 银盛-获取企业所属行业
     *
     * @return
     */
    @ApiOperation(value = "获取企业所属行业", notes = "获取企业所属行业")
    @GetMapping("/getCompanyKind")
    public R getCompanyKind(@RequestParam Map<String, Object> params) {
        return sysconfigFeign.getKeyCompanyKind(params);
    }

    /**
     * 银盛-获取银行账户类型
     *
     * @return
     */
    @ApiOperation(value = "获取银行账户类型", notes = "获取银行账户类型")
    @GetMapping("/getBankAccountType")
    public R getBankAccountType(@RequestParam Map<String, Object> params) {
        return sysconfigFeign.getBankAccountType(params);
    }

    /**
     * 银盛-获取银行卡类型
     *
     * @return
     */
    @ApiOperation(value = "获取银行卡类型", notes = "获取银行卡类型")
    @GetMapping("/getBankCardType")
    public R getBankCardType(@RequestParam Map<String, Object> params) {
        return sysconfigFeign.getBankCardType(params);
    }

    /**
     * 获取银行卡号，银行名称，开户行的地址，开户行用户名，银行卡类型，收款方账户类型
     *
     * @return
     */
    @ApiOperation(value = "获取商户银行卡相关信息", notes = "获取银行卡类型")
    //@GetMapping("/getStoreBankInfo")
    @RequestMapping("/getStoreBankInfo")
    public R getStoreBankInfo(@RequestParam Map<String, Object> params) {
        return chainStoresApiService.getStoreBankInfo(params);
    }

    /**
     * 获取银盛商户号和报备状态
     * @param params
     * @return
     */
    @ApiOperation(value = "获取银盛商户号和报备状态", notes = "获取银盛商户号和报备状态")
    @PostMapping("/getYsUserInfo")
    public R getYsUserInfo(@RequestParam Map<String, Object> params) {
        return chainStoresApiService.getYsUserInfo(params);
    }



    /**
     * 获取某商户的距离
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "获取某商户的距离", notes = "获取某商户的距离")
    @GetMapping("/getDistance")
    public R getDistance(@RequestParam Map<String, Object> params) {
        return chainStoresApiService.getDistance(params);
    }




}
